function [avgSC,avgSL]=surrogateNet(connectionM,iter,times)

%iter=1;
%times=50;
c=zeros(1,times); %cluster coefficient
l=zeros(1,times); %efficiency

for i=1:times
    %rwm=randmio_und_connected(connectionM,iter);  
    rwm=randWeightedGraph(connectionM);
    [c(i),l(i)]=graphMeasure(rwm);
end
avgSC=mean(c);
avgSL=mean(l);

function [connectionM]=randWeightedGraph(connectionM)

nCh=length(connectionM);

for i=1:nCh
    for j=i+1:nCh
        a=randi(nCh-1,1);
        b=1;
        tel=0;
        
        while(b<=a && tel<1000)
            tel=tel+1;
            b=randi(nCh,1);
        end
        
        old=connectionM(i,j);
        connectionM(i,j)=connectionM(a,b);
        connectionM(a,b)=old;
        
        old=connectionM(j,i);
        connectionM(j,i)=connectionM(b,a);
        connectionM(b,a)=old;
       
    
    end
end